package com.letao.controller;

import com.letao.common.pojo.EUDataGridResult;
import com.letao.common.pojo.LetaoResult;
import com.letao.pojo.TbItem;
import com.letao.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by ac on 2017/1/9.
 */
@Controller
@RequestMapping("/item")
public class ItemController {

    @Autowired
    private ItemService itemService;

    @RequestMapping("/{itemID}")
    @ResponseBody
    public TbItem test(@PathVariable Long itemID){
        return itemService.findItemByID(itemID);
    }

    @RequestMapping("/list")
    @ResponseBody
    public EUDataGridResult test(@RequestParam Integer page,
                                 @RequestParam Integer rows){
        return itemService.getItemList(page, rows);
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ResponseBody
    public LetaoResult save(TbItem item, String desc, String itemParams){
        //使用pojo接收表单内容
        LetaoResult result = itemService.createItem(item, desc, itemParams);
        return result;
    }


}
